package com.hundred.item.manager.impl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hundred.home.module.screen.Index;
import com.hundred.item.dao.TopItemDAO;
import com.hundred.item.dao.dataobject.ItemDO;
import com.hundred.item.dao.dataobject.TopItemDO;
import com.hundred.item.manager.ItemManager;
import com.hundred.item.manager.TopItemManager;

public class TopItemManagerImpl implements TopItemManager {

	private static final Logger logger = LoggerFactory.getLogger(TopItemManagerImpl.class);
	
	private TopItemDAO topItemDAO;
	
	private ItemManager itemManager;
	
	public List<ItemDO> getTopItemList(long number) {
		
		List<TopItemDO> topItemList = this.topItemDAO.queryTopItemList(number);
		
		if(topItemList!=null && topItemList.size()>0){
			
			List<ItemDO> resultList = new ArrayList<ItemDO> ();	
			for(TopItemDO topItem:topItemList){
				ItemDO itemDO = itemManager.getHistoryItemById(topItem.getItemId());
				resultList.add(itemDO);
			}
			logger.error("(=@__@=)---->Top:"+resultList.size());
			return resultList;
		}
		
		return new ArrayList<ItemDO> ();
		
	}

	public TopItemDAO getTopItemDAO() {
		return topItemDAO;
	}

	public void setTopItemDAO(TopItemDAO topItemDAO) {
		this.topItemDAO = topItemDAO;
	}

	public ItemManager getItemManager() {
		return itemManager;
	}

	public void setItemManager(ItemManager itemManager) {
		this.itemManager = itemManager;
	}

}
